from django.db import models
from apilogin.models import *


class Tower(models.Model):
    """
        @author: 成晨
        @date: 10/23/2018
        @整理：董海明
        本模型为楼，关联了用户
            字段名：user:关联用户、tower_name:楼名
    """
    user = models.ForeignKey(User, on_delete=models.CASCADE, null=True, blank=True)
    tower_name = models.CharField(max_length=200, unique=True)
    

class Floor(models.Model):
    """
        @author: 成晨
        @date: 10/23/2018
        @整理：董海明
        本模型为楼层，关联了用户和楼
            字段：user:关联用户、 tower：关联楼、floor_num:楼层
    """
    user = models.ForeignKey(User, on_delete=models.CASCADE, null=True, blank=True)
    tower = models.ForeignKey(Tower, on_delete=models.CASCADE)
    floor_num = models.CharField(max_length=10)


class Room(models.Model):
    """
        @author: 成晨
        @date: 10/23/2018
        @整理：董海明
        本模型为房间，关联了用户和楼层
            字段：user:关联用户、floor:关联楼层、room_num:房间号
    """
    user = models.ForeignKey(User, on_delete=models.CASCADE, null=True, blank=True)
    floor = models.ForeignKey(Floor, on_delete=models.CASCADE)
    room_num = models.CharField(max_length=10)
